package com.code.common.exception;

import com.code.common.model.ErrorCode;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: Yan
 * @date: 2023/03/29
 *
 * 统一异常错误
 */
public class ServiceException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private Object object;
    private ErrorCode errorCode;

    public ServiceException(String message) {
        super(message);
    }

    public ServiceException(String message, Object object) {
        super(message);
        this.object = object;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    public ServiceException(ErrorCode errorCode) {
        super(errorCode.getMsg());
        this.errorCode = errorCode;
    }

    public ServiceException(ErrorCode errorCode, Object object) {
        super(errorCode.getMsg());
        this.errorCode = errorCode;
        this.object = object;
    }

    public Object getObject() {
        return object;
    }

    public ErrorCode getResponseCode() {
        return errorCode;
    }
}
